package com.freshminds.saudiproject;

import java.util.ArrayList;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ImageView;
import android.widget.ListView;

public class MostViewed extends Activity implements OnItemClickListener
{
	ListView listView;
	//String strArray[]=new String[]{"a","a","a","a","a","a","a","a","a","a"};
	ArrayList<Video> videos;

	ImageView imgVwBack;
	
	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_most_viewed);
		listView=(ListView)findViewById(R.id.listView1);
		
		imgVwBack=(ImageView)findViewById(R.id.ximgVwBack);
		imgVwBack.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				finish();
			}
		});
		addVideoData();
		VideoAdapter adapter=new VideoAdapter(MostViewed.this, videos);
		listView.setAdapter(adapter);
		listView.setOnItemClickListener(this);
		findBottomMenuView();
		
	}
	
	
	void addVideoData()
	{
		videos=new ArrayList<Video>();
		
		Video video =new  Video();
		video.setId(1);
		video.setTitle("Tutorial 1");
		video.setVideoUrl("http://www.google.com");
		video.setRating(3);
		videos.add(video);
		
		video =new  Video();
		video.setId(1);
		video.setTitle("Tutorial 2");
		video.setVideoUrl("http://www.google.com");
		video.setRating(4);
		videos.add(video);
		
		video =new  Video();
		video.setId(1);
		video.setTitle("Tutorial 3");
		video.setVideoUrl("http://www.google.com");
		video.setRating(1);
		videos.add(video);
		
		video =new  Video();
		video.setId(1);
		video.setTitle("Tutorial 4");
		video.setVideoUrl("http://www.google.com");
		video.setRating(2);
		videos.add(video);
		
		
		video =new  Video();
		video.setId(1);
		video.setTitle("Tutorial 5");
		video.setVideoUrl("http://www.google.com");
		video.setRating(3);
		videos.add(video);
		
		video =new  Video();
		video.setId(1);
		video.setTitle("Tutorial 6");
		video.setVideoUrl("http://www.google.com");
		video.setRating(1);
		videos.add(video);
		
		video =new  Video();
		video.setId(1);
		video.setTitle("Tutorial 7");
		video.setVideoUrl("http://www.google.com");
		video.setRating(3);
		videos.add(video);
		
		video =new  Video();
		video.setId(1);
		video.setTitle("Tutorial 8");
		video.setVideoUrl("http://www.google.com");
		video.setRating(5);
		videos.add(video);
		
		video =new  Video();
		video.setId(1);
		video.setTitle("Tutorial 9");
		video.setVideoUrl("http://www.google.com");
		video.setRating(1);
		videos.add(video);	
	}
	
	
	void findBottomMenuView()
	{
		ImageView imgVwFeatured,imgVwMostViewed,imgVwMyFavourites,imgVwSendToFriend;
		
		imgVwFeatured=(ImageView)findViewById(R.id.ximgVwFeatured);
		imgVwMostViewed=(ImageView)findViewById(R.id.ximgVwMostViewed);
		imgVwMyFavourites=(ImageView)findViewById(R.id.ximgVwMyFavourites);
		imgVwSendToFriend=(ImageView)findViewById(R.id.ximgVwSendToFriend);
		
		imgVwFeatured.setOnClickListener(new OnClickListener() 
		{
			
			@Override
			public void onClick(View v) 
			{
				Utility utility=new Utility(MostViewed.this);
				utility.showToast("Button Clicked");
				
			}
		});
		
		imgVwMostViewed.setOnClickListener(new OnClickListener() 
		{
			
			@Override
			public void onClick(View v) 
			{
				Utility utility=new Utility(MostViewed.this);
				utility.showToast("Button Clicked");
				
			}
		});
		
		imgVwMyFavourites.setOnClickListener(new OnClickListener() 
		{
			
			@Override
			public void onClick(View v) 
			{
				Utility utility=new Utility(MostViewed.this);
				utility.showToast("Button Clicked");
				
			}
		});

		imgVwSendToFriend.setOnClickListener(new OnClickListener()
		{
	
			@Override
			public void onClick(View v) 
			{
				Utility utility=new Utility(MostViewed.this);
				utility.showToast("Button Clicked");
				
			}
		});
		
		
		
		
	}


	@Override
	public void onItemClick(AdapterView<?> arg0, View view, int position, long id) 
	{
		startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(videos.get(position).getVideoUrl())));
		
	}
}
